/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.diego.games.tetris.layer.block;

import br.diego.games.tetris.interfaces.IBlock;
import br.diego.games.tetris.layer.Constant;
import javax.microedition.lcdui.game.Layer;
import javax.microedition.lcdui.game.TiledLayer;

/**
 *
 * @author diego
 */
public class Square implements  IBlock{

    public static int COLOR = Constant.RED;
    private int tiles[][] = {{COLOR, COLOR},{COLOR, COLOR}};
    public TiledLayer layer;

    public int[][] getTiles() {
        return tiles;
    }

    public void setTiles(int[][] tiles) {
        this.tiles = tiles;
    }

    public Layer getTiledLayer() throws java.io.IOException {
        if (layer == null) {
            int mRow = this.tiles.length;
            int mCol = this.tiles[0].length;
            layer = new TiledLayer(mCol, mRow, Constant.getImage(), Constant.HEIGHT, Constant.WIDTH);
            for (int row = 0; row < mRow; row++) {
                for (int col = 0; col < mCol; col++) {
                    layer.setCell(col, row, tiles[row][col]);
                }
            }
        }
        return layer;
    }
    public int color() {
        return color();
    }
}
